# from typing import List
#
# from pydantic import BaseModel, Field
# from industry.dtos import CarDto
#
#
# class RoleDto(BaseModel):
#     id: int = Field(default=0, title="id", description="id")
#     name: str = Field(default=None, title="名称", description="名称")
#
#     class Config:
#         from_attributes = True
#         orm_mode = True
#
#
# class UserDto(BaseModel):
#     id: int = Field(default=0, title="id", description="id")
#     name: str = Field(default=None, title="名称", description="名称")
#     password: str = Field(default=None, title="密码", description="密码")
#     role_ids: List[int] = Field(default=[], title="角色ids", description="角色ids")
#     roles: List[RoleDto] = Field(default=[], title="角色对象集合", description="角色对象集合")
#     cars: List[CarDto] = Field(default=[], title="车辆集合", description="车辆集合")
#
#     class Config:
#         from_attributes = True
#         orm_mode = True
#
# #
# # def user_model2dto(item: User):
# #     user = UserDto(id=item.id, name=item.name, password="", roleIds=[], roles=[], cars=[])
# #     for role in item.roles:
# #         user.roleIds.append(role.id)
# #         user.roles.append(RoleDto(id=role.id, name=role.name))
# #     for car in item.cars:
# #         user.cars.append(CarDto(id=car.id, name=car.name, userId=car.user_id, producerName=car.producer.name, nationName=car.producer.nation.name))
# #     return user
